/**
 * Class: HTML FORMATTER
 * Description:
 * 
 */
import java.util.Date;

import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;



/**
 * @author Team Awesome Express
 * @version $ 1.0 Revision $
 */
class HTMLFormatter extends Formatter {
    // This method is called for every log records
    /**
     * Method format.
     * @param rec LogRecord
     * @return String
     */
    public String format(LogRecord rec) {
        StringBuffer buf = new StringBuffer(1000); // $codepro.audit.disable numericLiterals, variableShouldBeFinal
        // Bold any levels >= WARNING
        if (rec.getLevel().intValue() >= Level.WARNING.intValue()) {
            buf.append("<b>");
            buf.append(rec.getLevel());
            buf.append("</b>");
        } else {
            buf.append(rec.getLevel());
        }
        buf.append(' ');
        buf.append(rec.getMillis());
        buf.append(' ');
        buf.append(formatMessage(rec));
        buf.append('\n');
        return buf.toString();
    }

    // This method is called just after the handler using this
    // formatter is created
    /**
     * Method getHead.
     * @param h Handler
     * @return String
     */
    public String getHead(Handler h) {
        return "<HTML><HEAD>" + (new Date()) + "</HEAD><BODY><PRE>\n";
    }

    // This method is called just after the handler using this
    // formatter is closed
    /**
     * Method getTail.
     * @param h Handler
     * @return String
     */
    public String getTail(Handler h) {
        return "</PRE></BODY></HTML>\n";
    }
}

